package com.wandian.audio.mvvm.audiodj;

import android.os.Bundle;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.mvvm.BaseMVVMActivity;
import com.mylib.libcore.utils.ActivityUtil;
import com.wandian.audio.R;
import com.wandian.audio.adapter.AudioDJTopRecycleAdapter;
import com.wandian.audio.databinding.AudioActivityDjBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 * @date 2019/12/18-14:28
 * @description DJ_activity
 **/
@Route(path = RouterConfig.ROUTER_ACTIVITY_AUDIO_DJ)
public class AudioDJActivity extends BaseMVVMActivity<AudioDJActivityViewModel> {
    private AudioActivityDjBinding dataBinding;
    private AudioDJTopRecycleAdapter audioDJTopRecycleAdapter;
    @Override
    public void init(Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.audio_activity_dj);
        dataBinding.setLifecycleOwner(this);
        dataBinding.setViewModel(mViewModel);
        initRecycle();
        initViewData();
        initClink();
        mViewModel.getMusicRank();
    }

    private void initRecycle(){
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
        dataBinding.recycler.setLayoutManager(layoutManager);
        audioDJTopRecycleAdapter  = new AudioDJTopRecycleAdapter(R.layout.audio_item_dj_home_view);
        dataBinding.recycler.setAdapter(audioDJTopRecycleAdapter);
        List<String> listTitle = new ArrayList<>();
        listTitle.add("今日推荐");
        listTitle.add("人气推荐");
        listTitle.add("最新推荐");
        listTitle.add("收藏推荐");
        listTitle.add("作者推荐");
        audioDJTopRecycleAdapter.setNewData(listTitle);
        audioDJTopRecycleAdapter.setOnItemClickListener((adapter, view, position) -> {
            switch (position){
                case 0:
                    ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_AUDIO_MUSIC_RANK_DJ).withString("title","今日推荐").navigation();
                    break;
                case 1:
                    ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_AUDIO_MUSIC_RANK_DJ).withString("title","人气榜").navigation();
                    break;
                case 2:
                    ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_AUDIO_MUSIC_RANK_DJ).withString("title","新歌榜").navigation();
                    break;
                case 3:
                    ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_AUDIO_MUSIC_RANK_DJ).withString("title","收藏榜").navigation();
                    break;
                case 4:
                    ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_AUDIO_AUTHOR_RANK).withString("title","作者").navigation();
                    break;
            }
        });
    }

    private void initViewData(){
        ActivityUtil.getInstance().showStatusView(this,dataBinding.viewSysTop,true);
        dataBinding.bindTransparentToolBar.toolBarTvTitle.setText("DJ天地");
    }

    private void initClink(){
        dataBinding.bindTransparentToolBar.toolBarIvBack.setOnClickListener(v -> {
            finish();
        });
    }



}
